package com.luoyuanxiangvip.core.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luoyuanxiangvip.core.entity.BizArticleTag;
import com.luoyuanxiangvip.core.mapper.BizArticleTagMapper;
import com.luoyuanxiangvip.core.service.IBizArticleTagService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 文章和标签中间表 服务实现类
 * </p>
 *
 * @author luoyuanxiang <p>luoyuanxiangvip.com</p>
 * @since 2019-05-30
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class BizArticleTagServiceImpl extends ServiceImpl<BizArticleTagMapper, BizArticleTag> implements IBizArticleTagService {

    /**
     * 通过文章 id 查找标签 id
     *
     * @param id 文章 id
     * @return 标签 id
     */
    @Override
    public List<Long> findByArticleId(Long id) {
        return this.baseMapper.findByArticleId(id);
    }

    /**
     * 根据标签 id 查询文章 id
     *
     * @param id 标签id
     * @return 文章id
     */
    @Override
    public List<Long> findByTagId(Long id) {
        return this.baseMapper.findByTagId(id);
    }

    /**
     * 通过 标签id查询文章数
     *
     * @param id 标签id
     * @return 文章数
     */
    @Override
    public Long countByTagId(Long id) {
        return this.baseMapper.countByTagId(id);
    }
}
